#include <stdio.h>
#include <stdlib.h>

#define MAXSIZE 10
#define NotFound 0
typedef int ElementType;

typedef int Position;
typedef struct LNode *List;
struct LNode {
    ElementType Data[MAXSIZE];//一般会在开辟空间的后面特别加上1来强调下标从1开始
    Position Last; /* 保存线性表中最后一个元素的位置 */
};

List ReadInput(); /* 裁判实现，细节不表。元素从下标1开始存储 */
Position BinarySearch( List L, ElementType X );

int main()
{
    List L;
    ElementType X;
    Position P;

    L = ReadInput();
    scanf("%d", &X);
    P = BinarySearch( L, X );
    printf("%d\n", P);

    return 0;
}
Position BinarySearch( List L, ElementType X ) {
    int low = 1; 
    int high = L->Last;
    while(low <= high) {

        int mid = low + (high - low) / 2;//防止溢出
        if (L->Data[mid] > X) {
            high = mid - 1;
        }
        else if (L->Data[mid] < X) {
            low = mid + 1;
        }
        else if (L->Data[mid] == X) {
            return mid;
        }
    }
    return NotFound;
}
